.redactor-box {
	background-color: $wcfContentBackground;
	position: relative;
	
	&:not(:first-child):not(.redactorBoxFullscreen) {
		margin-top: 20px;
	}
	
	& + .messageTabMenu {
		padding: 0;
	}
	
	& + .innerError,
	> .innerError {
		border-radius: 0;
		box-shadow: none;
		display: block;
		margin-top: -1px;
	}
	
	> .innerError {
		margin: -1px 0;
	}
}

.redactor-layer {
	border: 1px solid $wcfContentBorderInner;
	border-top-width: 0;
	max-height: 500px;
	padding: 10px;
	position: relative;
	outline: none;
	overflow: auto;
	
	* {
		// setting min-width to "0" inside contenteditable causes
		// IE11 to do all sort of funny things
		min-width: auto;
	}
	
	&.redactor-placeholder::after {
		color: $wcfContentDimmedText;
		content: attr(placeholder);
		display: block;
		pointer-events: none;
		position: absolute;
	}
	
	& + textarea {
		border-width: 0;
		box-shadow: none;
		outline: none;
		padding: 10px;
		resize: vertical;
		
		&:focus {
			box-shadow: none;
		}
	}
	
	// enforce styles used in messages
	@extend .htmlContent;
	
	> :not(p) {
		&:first-child {
			margin-top: 10px !important;
		}
		
		&:last-child {
			margin-bottom: 20px !important;
		}
	}
	
	// remove margin top for the first paragraph in the editor to avoid a weird looking offset a the top
	> p:first-child {
		margin-top: 0;
	}
	
	img {
		max-width: 100%;
		
		&:not(.smiley) {
			// show cursor to indicate editing capability excluding smilies
			cursor: pointer;
		}
		
		/* prevent flicker from pasted images */
		&[src^="data:image"] {
			display: none !important;
		}
	}
	
	table {
		border-collapse: collapse;
		line-height: 1.6em;
		
		th {
			border: 1px solid #ddd;
			border-bottom: 2px solid currentColor;
		}
		
		td {
			border: 1px solid #ddd;
			padding: 5px;
			vertical-align: top;
			
			&:empty::before {
				content: "";
				display: inline-block;
			}
		}
	}
	
	/* This is a rather hacky work-around for Safari that makes the bottom margin clickable
	   in order to recognize clicks in between two block elements. See #2533 */
	&.jsSafariMarginClickTarget {
		pre,
		woltlab-quote,
		woltlab-spoiler {
			&::after {
				content: "";
				height: 1em; // this is the value of `margin-bottom`
				left: 0;
				position: absolute;
				right: 0;
				
				@include screen-md-up {
					transform: translateY(20px); // this is the value of `padding-bottom`
				}
				
				@include screen-sm-down {
					transform: translateY(10px); // this is the value of `padding-bottom`
				}
			}
		}
		
		pre::after {
			/* parent is `position: relative` */
			bottom: 0;
		}
	}
}

.redactor-dropdown {
	> .dropdownMenu {
		display: block;
		position: relative;
		visibility: visible;
		
		@include screen-lg {
			top: 1px;
		}
		
		> li:hover {
			background-color: transparent !important;
		}
		
		a:hover {
			background-color: $wcfDropdownBackgroundActive;
		}
	}
	
	.redactor-dropdown-link-inactive {
		cursor: default;
		opacity: .6;
		
		> a:hover {
			background-color: $wcfDropdownBackground !important;
			color: $wcfDropdownText !important;
			cursor: default !important;
		}
	}
}

/* disable auto zoom in mobile safari */
@include screen-md-down {
	.redactor-layer {
		font-size: 16px;
		max-height: 500px;
	}
}

.redactor-toolbar {
	background-color: $wcfHeaderBackground;
	display: flex;
	flex-wrap: wrap;
	
	> li {
		flex: 0 0 auto;
		
		> a {
			color: $wcfHeaderMenuLink;
			display: block;
			outline: none;
			padding: 10px;
			text-align: center;
			
			@include wcfFontSmall;
			
			&.redactor-button-disabled {
				background-color: transparent !important;
				color: $wcfButtonDisabledText !important;
				cursor: default;
				pointer-events: none;
			}
			
			&.redactor-act,
			&.dropact {
				background-color: $wcfHeaderMenuLinkBackgroundActive;
				color: $wcfHeaderMenuLinkActive;
			}
			
			.icon {
				color: inherit;
				cursor: inherit !important;
				
				&.redactorButtonImage {
					background: no-repeat center center;
					background-size: contain;
				}
			}
			
			@include screen-lg {
				// hover-styles on mobile are misleading as they stay much longer
				// due to the click-like behavior
				&:hover {
					background-color: $wcfHeaderMenuLinkBackgroundActive;
					color: $wcfHeaderMenuLinkActive;
				}
			}
		}
		
		@include screen-sm-up {
			&.redactor-toolbar-separator {
				margin-left: 11px;
				position: relative;
				
				&::before {
					bottom: 7px;
					border-left: 1px solid $wcfHeaderMenuLink;
					content: "";
					left: -6px;
					opacity: .6;
					position: absolute;
					top: 7px;
				}
			}
		}
	}
	
	@include screen-xs {
		&:not(.redactorToolbarOverride) > li {
			&[data-show-on-mobile="false"] {
				display: none;
			}
		}
		
		&.redactorToolbarOverride > .redactor-toolbar-separator {
			position: relative;
			
			&::before {
				bottom: 7px;
				border-left: 1px solid $wcfHeaderMenuLink;
				content: "";
				left: 0;
				opacity: .6;
				position: absolute;
				top: 7px;
			}
		}
		
		.redactorToolbarToggle {
			position: relative;
			
			&::before {
				bottom: 7px;
				border-left: 1px solid $wcfHeaderMenuLink;
				content: "";
				left: 0;
				opacity: .6;
				position: absolute;
				top: 7px;
			}
		}
	}
}

.redactor-toolbar-tooltip {
	@extend .balloonTooltip;
	
	opacity: 1;
	visibility: visible;
}

.redactorAttachmentContainer {
	background-color: rgba(255, 255, 255, 1);
	border: 1px solid rgba(238, 238, 238, 1);
	border-top-width: 0;
	padding: 7px 14px 7px;
}

.redactor-dropdown-box-fontcolor {
	width: 200px;
	
	> li.redactorColorPallet {
		padding: 0 4px;
		
		&:hover {
			background-color: $wcfDropdownBackground !important;
		}
		
		> a {
			border: 2px solid rgba(255, 255, 255, 1);
			border-bottom-width: 0;
			display: inline-block;
			font-size: 0;
			height: 20px;
			padding: 0;
			margin: 0;
			width: 20px;
		}
	}
}

.redactorDropArea {
	align-items: center;
	background-color: $wcfStatusInfoBackground;
	border: 5px dashed currentColor;
	bottom: 0;
	color: $wcfStatusInfoText;
	display: flex;
	justify-content: center;
	left: 0;
	position: absolute;
	right: 0;
	z-index: 10;
	
	@include wcfFontSection;
	
	&::before {
		content: attr(data-drop-here);
	}
	
	&.active {
		background-color: $wcfStatusSuccessBackground;
		color: $wcfStatusSuccessText;
		
		&::before {
			content: attr(data-drop-now);
		}
	}
}

.redactor-link-tooltip {
	background-color: $wcfTooltipBackground;
	border-radius: 2px;
	box-shadow: 0 0 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24);
	color: $wcfTooltipText;
	padding: 5px 10px 7px;
	position: absolute;
	z-index: 800;
	
	> a {
		color: $wcfTooltipText;
	}
}

.redactor-voice-label {
	display: none;
}

/* format */
.redactor-dropdown-h2 {
	@include wcfFontSection;
}

.redactor-dropdown-h3 {
	@include wcfFontHeadline;
}

.redactor-dropdown-h4 {
	// TODO: add styling
}

/* alignment plugin */
.text-center {
	text-align: center !important;
}

.text-right {
	text-align: right !important;
}

/* alignment plugin / custom value */
.text-justify {
	text-align: justify !important;
	
	-webkit-hyphens: auto;
	-moz-hyphens: auto;
	-ms-hyphens: auto;
	hyphens: auto;
}

/* text color selection */
.redactor-dropdown-box-woltlabColor {
	> ul {
		display: flex !important;
		flex-wrap: wrap;
		width: 272px;
		
		> .dropdownDivider,
		> .dropdownDivider + li {
			flex: 0 0 100%;
		}
	}
	
	.woltlab-color-selection {
		flex: 0 0 30px;
		margin: 2px;
		overflow: hidden;
		
		> a {
			background-color: currentColor !important;
			display: block;
			height: 30px;
			width: 30px;
		}
	}
}

/* font size */
.woltlab-size-8 { font-size: 8pt; }
.woltlab-size-10 { font-size: 10pt; }
.woltlab-size-12 { font-size: 12pt; }
.woltlab-size-14 { font-size: 14pt; }
.woltlab-size-18 { font-size: 18pt; }
.woltlab-size-24 { font-size: 24pt; }
.woltlab-size-36 { font-size: 36pt; }

/* image float */
.messageFloatObjectLeft {
	float: left;
	margin: 0 20px 20px 0;
}

.messageFloatObjectRight {
	float: right;
	margin: 0 0 20px 20px;
}

.smiley,
.jsSmiley > img {
	&[src$="_emojione.png"] {
		max-height: 20px;
	}
}

.smiley {
	margin: 0 1px;
}

@include screen-md-down {
	.jsSmiley {
		display: inline-block;
		padding: 10px;
	}
}

.wysiwygTextarea {
	background-color: transparent !important;
	border: 1px solid $wcfContentBorderInner !important;
	color: transparent !important;
	display: block;
	height: 238px;
	width: 100%;
}

.messageQuickReplyCollapsed {
	border-bottom-width: 0 !important;
	
	@include screen-sm-down {
		margin-left: -10px;
		margin-right: -10px;
	}
	
	.messageSidebar {
		display: none;
	}
	
	.messageQuickReplyContent {
		background-color: $wcfSidebarBackground;
		cursor: pointer;
		display: inline-block !important;
		margin: 0 !important;
		max-width: 100% !important;
		overflow: hidden;
		padding: 10px 20px;
		position: relative;
		width: 100% !important;
		
		@include screen-md-up {
			border-radius: 2px;
		}
		
		&::before {
			color: $wcfSidebarText;
			content: $fa-var-reply;
			font-family: FontAwesome;
			font-size: 28px;
			height: 32px;
			line-height: 32px;
			margin-right: 10px;
			width: 32px;
			vertical-align: -5px;
		}
		
		&::after {
			color: $wcfSidebarText;
			content: attr(data-placeholder);
			
			@include screen-sm-up {
				@include wcfFontSection;
			}
		}
		
		> .messageBody {
			left: 200%;
			position: absolute;
			top: -100%;
		}
		
		> .messageFooter {
			display: none;
		}
	}
}

.redactorAutosaveRestored {
	background-color: $wcfContentBackground;
	border-top: 1px solid $wcfContentBorderInner;
	bottom: 1px;
	display: flex;
	opacity: 0;
	position: absolute;
	right: 1px;
	transition: opacity .12s linear, visibility 0s linear .12s;
	visibility: hidden;
	
	&.active {
		opacity: 1;
		transition-delay: 0s;
		visibility: visible;
	}
	
	> a {
		border-left: 1px solid $wcfContentBorderInner;
		flex: 0 0 auto;
		padding: 10px;
	}
	
	> span {
		color: $wcfContentDimmedText;
		flex: 1 1 auto;
		padding: 10px;
	}
	
	@include screen-sm-up {
		border-left: 1px solid $wcfContentBorderInner;
		border-top-left-radius: 2px;
		
		> span {
			padding: 10px 20px;
		}
	}
	
	@include screen-xs {
		left: 1px;
		
		> span {
			text-align: center;
		}
	}
}

.redactorBoxFullscreen {
	bottom: 0;
	left: 0;
	position: fixed;
	right: 0;
	top: 0;
	z-index: 310;
	
	.redactor-layer {
		max-height: none !important;
		min-height: 0 !important;
	}
}
